|
|
 |
|
|
|
|
ByRef token_name As String, ByRef token_value As String)
Dim pos1 As Integer
Dim pos2 As Integer
Dim open_parens As Integer
Dim ch As String
' Find the "(". pos1 = InStr(txt, "(")
If pos1 = 0 Then ' No "(" found. Return the rest as the token name. token_name = Trim$(txt)
token_value = ""
txt = ""
Exit Sub
End If
' Find the corresponding ")". Note that
' parentheses may be nested. open_parens = 1
pos2 = pos1 + 1
Do While pos2 <= Len(txt)
ch = Mid$(txt, pos2, 1)
If ch = "(" Then
open_parens = open_parens + 1
ElseIf ch = ")" Then
open_parens = open_parens - 1
If open_parens = 0 Then ' This is the corresponding ")". Exit Do
End If
End If
pos2 = pos2 + 1
Loop
' At this point, pos1 points to the ( and
' pos2 points to the ). token_name = Trim$(Left$(txt, pos1 - 1))
token_value = Trim$(Mid$(txt, pos1 + 1, pos2 - pos1 - 1))
txt = Trim$(Mid$(txt, pos2 + 1))
End Sub |
|
|
|
|
|
|
|
|
This method of using object serializations to save and restore object properties has a couple of benefits. First, the serializations are simple strings. You can save them in files, database fields, or any other medium that works with text. You could pass a serialization to an ActiveX control on a Web page and make the control display the drawing objects in the browser. You could e-mail a serialization to someone who has a program that can read serializations. |
|
|
|
|
|
|
|
|
This system promotes backward compatibility. If a later version of your program creates a new object property type, your program will still be able to read older serializations. For example, suppose you add a ForeColor property to the TwoDLine class. When |
|
|
|
|
|